<?php
include_once 'app/until/GFW_database.php';

class Db_user_page_explorer extends Model_Db_Core {

	private $con = null;
	private $username;
	private $Explorer;

	function __construct(){

	}

	public function getExplorer($user_id){		
		$filter  = array('user_id'=> $user_id);
	    $select  = array();
	    
	    parent::getSQLResult(__CLASS__,$filter,$select,0,99);
	    $this->Explorer = parent::result();

	    return $this->Explorer;
	}
    public function getModulPage($user_id,$modul_id){		
		$filter  = array('user_id'=> $user_id,'modul_nr'=> $modul_id);
	    $select  = array();
	    
	    parent::getSQLResult(__CLASS__,$filter,$select);
	    $this->page = parent::result(1);

	    return $this->page;
	}
	public function getUserNavigation($user_id){	
		$sql = 'Select name, url from user_page_explorer where navi = 0 and user_id = '.$user_id.' ORDER BY navi_posi ASC';
		
		parent::setSqlManuel($sql);
	    $this->Explorer = parent::result();
	    		
		return $this->Explorer;
	}
	public function getUserNavigationModul($user_id){	
		$sql = 'Select name, modul_nr from user_page_explorer where modul_nr IS NOT NULL and user_id = '.$user_id.' ORDER BY navi_posi ASC';

		parent::setSqlManuel($sql);
	    $this->Explorer = parent::result();
	    		
		return $this->Explorer;
	}
    public function setModul($value){
	    parent::setInsert(__CLASS__);
		 	 	
	    if(array_key_exists("user_id",$value)){
		    $this->value['user_id'] = $value["user_id"];	        
	    }
        if(array_key_exists("name",$value)){
		    $this->value['name'] = $value["name"];	        
	    }
	    if(array_key_exists("slogen",$value)){
		    $this->value['slogen'] = $value["slogen"];	        
	    }
	    if(array_key_exists("titel",$value)){
		    $this->value['titel'] = $value["titel"];	        
	    }
	    if(array_key_exists("url",$value)){
		    $this->value['url'] = $value["url"];	        
	    }
	    if(array_key_exists("aktiv",$value)){
		    $this->value['aktiv'] = $value["aktiv"];	        
	    }
	    if(array_key_exists("zugriff",$value)){
		    $this->value['zugriff'] = $value["zugriff"];	        
	    }
	    if(array_key_exists("passwort",$value)){
		    $this->value['passwort'] = $value["passwort"];	        
	    }
	    if(array_key_exists("navi",$value)){
		    $this->value['navi'] = $value["navi"];	        
	    }
	    if(array_key_exists("navi_posi",$value)){
		    $this->value['navi_posi'] = $value["navi_posi"];	        
	    }
	    if(array_key_exists("main_flag",$value)){
		    $this->value['main_flag'] = $value["main_flag"];	        
	    }
	    if(array_key_exists("modul_nr",$value)){
		    $this->value['modul_nr'] = $value["modul_nr"];	        
	    }
		
	    $status = $this->writeToDb();
	   
	    return $status;	   
	}
    public function updateModul($user_id,$page_id,$value){
	    parent::setInsert(__CLASS__);
		 	 	
        $this->where['user_id'] = $user_id;
        $this->where['id'] = $page_id;
        
        if(isset($value->name)){
		    $this->value['name'] = $value->name;	        
	    }
	    if(isset($value->slogen)){
		    $this->value['slogen'] = $value->slogen;	        
	    }
	    if(isset($value->titel)){
		    $this->value['titel'] = $value->titel;	        
	    }
	    if(isset($value->url)){
		    $this->value['url'] = $value->url;	        
	    }
	    if(isset($value->aktiv)){
		    $this->value['aktiv'] = $value->aktiv;	        
	    }
	    if(isset($value->zugriff)){
		    $this->value['zugriff'] = $value->zugriff;	        
	    }
	    if(!empty($value->passwort)){
		    $this->value['passwort'] = $value->passwort;	        
	    }
	    if(isset($value->navi)){
		    $this->value['navi'] = $value->navi;	        
	    }
	    if(isset($value->navi_posi)){
		    $this->value['navi_posi'] = $value->navi_posi;	        
	    }
	    if(isset($value->main_flag)){
		    $this->value['main_flag'] = $value->main_flag;	        
	    }
	    
	    $status = $this->writeToDb(true);
	   
	    return $status;	   
	}
	
}

?>